<div class="container main contact-container" ng-controller="ContactListCtrl">

    <div class="row">
        <div class="panel panel-default">
            <!-- Default panel contents -->
            <div class="panel-heading">
                <div class="text-center"><strong>{[moduleTitle|uppercase]}</strong></div>
                <div class="row">
                    <div class="col-md-4">
                        <span class="btn-group">
                            <button data-toggle="dropdown" class="btn btn-default dropdown-toggle">
                            <strong>Actions</strong>&nbsp;&nbsp;<i class="caret"></i></button>
                            <ul class="dropdown-menu">
                                <li>
                                    <a ng-click="" href="javascript:void(0);">Send Email (Unfinished)</a>
                                </li>

                                <li>
                                    <a ng-click="" href="javascript:void(0);">Add Comment (Unfinished)</a>
                                </li>

                                <li>
                                    <a ng-click="" href="javascript:void(0);">Add Tag (Unfinished)</a>
                                </li>

                                <li>
                                    <a ng-click="removeSelectedList(objects, query)" href="javascript:void(0);">Delete</a>
                                </li>

                                <li class="divider"></li>

                                <li>
                                    <a onclick="" href="javascript:void(0);">Import</a>
                                </li>

                                <li>
                                    <a onclick="" href="javascript:void(0);">Export</a>
                                </li>
                            </ul>
                        </span>
                        <span class="btn-group">
                            <button class="btn btn-primary pull-left" ng-click="addNew()">
                                <i class="glyphicon glyphicon-plus icon-white"></i> Add
                            </button>
                        </span>
                    </div>
                    <div class="col-md-8">
                        <form name="form_query" ng-submit="query()" class="form-inline pull-right">
                            <div class="form-group">
                                <label class="sr-only"></label>
                                <input type="text" class="form-control" ng-model="parameters.query" placeholder="Keywords" />
                            </div>

                            <div class="form-group">
                                <label class="sr-only"></label>
                                <select name="limit" ng-model="parameters.limit" class="form-control">
                                    <option value="20">20</option>
                                    <option value="30">30</option>
                                    <option value="50">50</option>
                                    <option value="100">100</option>
                                    <option value="0">Unlimited</option>
                                </select>
                            </div>
                            <button type="submit" class="btn btn-info">
                                <i class="glyphicon glyphicon-search icon-white"></i> Search
                            </button>
                        </form>
                    </div>
                </div>
            </div>

            <!-- Table -->
            <div ng-show="objects.length == 0" class="rounded_corners no_result">
                <p>No Contacts found. <a href="javascript:void(0)" ng-click="addNew()">Create Contact</a> </p>
            </div>
            <table class="table table-striped table-bordered table-condensed table-hover" ng-show="objects.length > 0" ts-wrapper>
                <thead>
                    <tr>
                        <th>
                            <select-all-checkbox checkboxes="objects" all-selected="AllSelectedItems"
                            all-clear="NoSelectedItems"></select-all-checkbox>
                        </th>
                        <th>#</th>
                        <th ts-criteria="first_name">First Name</th>
                        <th ts-criteria="last_name">Last Name</th>
                        <th ts-criteria="primary_email">Primary Email</th>
                        <th ts-criteria="office_phone">Office Phone</th>
                        <th ts-criteria="assigned_to_title">Assigned To</th>
                        <th></th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="obj in objects" ts-repeat="ts-repeat">
                        <td class="text-center">
                            <input type="checkbox" ng-model="obj.isSelected" />
                        </td>
                        <td>
                            <!--
                            <div class="pull-left">
                                <div class="tags">
                                    <div class="tag label btn-info" ng-repeat="i in obj.info.tags">
                                        <span>{[ i ]}</span>
                                    </div>
                                </div>
                            </div>-->
                            <a href="javascript:void(0)" ng-click="openContactDetail(obj.id)">{[ obj.slug ]}</a>
                        </td>
                        <td class="text-right editable-width-1">
                            <a href="javascript:void(0)"
                               editable-text="obj.first_name"
                               onbeforesave="patchDetail('contact', obj.id, {first_name: $data})">
                               {[ obj.first_name || 'empty' ]}
                            </a>
                        </td>
                        <td class="text-right editable-width-1">
                            <a href="javascript:void(0)"
                               editable-text="obj.last_name"
                               onbeforesave="patchDetail('contact', obj.id, {last_name: $data})">
                               {[ obj.last_name || 'empty' ]}
                            </a>
                        </td>

                        <td class="text-right">
                            <a href="javascript:void(0)"
                               editable-text="obj.primary_email"
                               onbeforesave="patchDetail('contact', obj.id, {primary_email: $data})">
                               {[ obj.primary_email || 'empty' ]}
                            </a>
                        </td>
                        <td class="text-right">
                            <a href="javascript:void(0)"
                               editable-text="obj.office_phone"
                               onbeforesave="patchDetail('contact', obj.id, {office_phone: $data})">
                               {[ obj.office_phone || 'empty' ]}
                            </a>
                        </td>
                        <td class="text-right">{[ obj.assigned_to_title ]}</td>
                        <td class="text-right">
                            <button type="button" class="btn btn-primary btn-xs" ng-click="edit(obj.id)">Edit</button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div ng-include="'/static/js/views/components/pager.html'" style="display: inline;"></div>


</div>